﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MS.InformationManagement.Core.Support;
using MS.InformationManagement.DAL.DocumentCenter;
using Microsoft.SharePoint;

namespace MS.InformationManagement.BLL.GestionDeUsuarios
{
    public class UpdateUserRolePermissionsCommand : BaseUserPermissionsCommand, IBaseCommand
    {
        
        #region Constructors

        public UpdateUserRolePermissionsCommand(string targetLoginUser, Roles currentRole) : base(targetLoginUser, currentRole) { }

        #endregion

        #region Implemented Methods

        public void Execute()
        {
            SPGroup roleGroup = getRoleGroup(_role);
            SPUser targetUser = getRoleUser(_targetLoginUser);
            roleGroup.AddUser(targetUser);
            roleGroup.Update();
        }

        public void Undo()
        {
            SPGroup roleGroup = getRoleGroup(_role);
            SPUser targetUser = getRoleUser(_targetLoginUser);
            roleGroup.RemoveUser(targetUser);
        }

        #endregion

    }
}
